package mth.weka.cltree;

public class Node {
	//Decision: use int Array for building Subsets of Dataset
	//possibly lower RAM requirement and probably faster computation
	
	private static int existingNodes=0;
	
	private boolean isLeaf;
	private int splitsOn; //to know how to descend in the tree
	private double splitValue;
	private Node[] childNodes; //child and parent to build a 2-way concatenated tree structure
	private Node parent;
	
	private int yPoints;
	private int nPoints;
	
	public static int numNodes() {
		return Node.existingNodes;
	}
	
	public Node () {
		nPoints=0;
		Node.existingNodes++;
	}
	
	public Node[] getChildNodes() {
		return this.childNodes;
	}
	
	public Node getParent() {
		return this.parent;
	}

	public int getSplitAttribute() {
		return this.splitsOn;
	}
	
	public double getSplitValue() {
		return splitValue;
	}

	public int getNPoints() {
		return this.nPoints;
	}
	
	public int getYPoints() {
		return this.yPoints;
	}
	
	public boolean isLeaf() {
		return this.isLeaf;
	}
	
	public void addChildNodes(Node leftChild, Node rightChild) {
		this.childNodes = new Node[2];
		this.childNodes[0] = leftChild;
		this.childNodes[1] = rightChild;
	}
	
	public void setParent(Node par) {
		this.parent = par;
	}
	
	public void setSplitAttrib(int splitAttribIndex) {
		splitsOn = splitAttribIndex;
	}
	
	public void setSplitValue(double splitVal) {
		this.splitValue = splitVal;
	}
	
	public void setLeafStatus(boolean newStatus) {
		this.isLeaf = newStatus;
	}
	
	public void setNPoints(int n) {
		this.nPoints = n;
	}
	
	public void setYPoints(int y) {
		this.yPoints = y;
	}
}
